﻿using System;
using blackenter.Data;
using Microsoft.CSharp;

namespace blackenter.Tests.FakeDbContexts {
    internal class TestDbContexts {

        internal FakeSiteDbContext SiteDbContext;
        internal FakePageDbContext PageDbContext;

        internal const int ExampleSiteId = 1;
        internal const string ExampleSiteName = "My Example Site";
        internal const string ExampleSiteName2 = "My Profesional Site";

        internal const string ExamplePageName = "My Example Page";
        internal const string ExamplePageName2 = "My Profesional Page";

        internal void InitializeSiteDbContext() {
            this.SiteDbContext = new FakeSiteDbContext();
            FakeSiteDbContext.Reset();
            DbFactory.SetSiteDbContext(typeof(FakeSiteDbContext));
        }

        internal void InitializePageDbContext() {
            this.PageDbContext = new FakePageDbContext();
            PageDbContext.Reset();
            DbFactory.SetPageDbContext(typeof(FakePageDbContext));
        }

        internal void AddExampleSite(int siteId = ExampleSiteId, string siteName = ExampleSiteName) {
            this.SiteDbContext.Sites.Add(new SiteData() { Id = siteId, Name = siteName });
        }

        internal void AddExamplePage(int siteId = ExampleSiteId, string pageName = ExamplePageName) {
            this.PageDbContext.Pages.Add(new PageData() { Id = this.PageDbContext.Pages.Count + 1, SiteId = siteId, Name = pageName, SiteCulture = String.Empty });
        }

    }
}
